<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="pl.org.waff.*" %>
<jsp:useBean id="sitenavigator" class="pl.org.waff.DefaultNavigator" scope="application" />
<jsp:useBean id="applicationprefix" class="java.lang.String" scope="application" />
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=applicationprefix%>/resources/homestyle.css" />
    <title>Waff demo</title>
    <jsp:include page="components/analytics.jsp"/>
</head>
<body>

    <div id="wrapper">
        <div id="header"><jsp:include page="components/header.jsp"/></div>
        <div id="menu"><jsp:include page="components/menu.jsp"/></div>
        <div id="breadcrumb"><jsp:include page="components/breadcrumb.jsp"/></div>
        <div id="main">
            <div id="content">
                <h1>Log out</h1>
                <%  User user = (User) request.getSession().getAttribute("waffuser");
                    String pathPrefixIfMobile = (String) request.getSession().getAttribute(WaffServlet.PATH_PREFIX_ATTRIBUTE_NAME);
                    if ("true".equals(request.getParameter("logout"))) {
                        user = WaffServlet.getUserManager().getUser(null, null);
                        request.getSession().setAttribute("waffuser", user);
                %>
                You've been logged out.<br/>
                If you want to log in again, go to <a href='<%=WaffServlet.getUserManager().createLoginURL(sitenavigator.getAbsolutePath("/login"))%>'>the login page</a>.
                <%
                } else {%>
                You are logged as <%=user.getName()%><br/>
                <form action=<%=sitenavigator.getAbsolutePath("/logout/_.do", pathPrefixIfMobile)%>>
                    <input type="hidden" name="logout" value="true"></input>
                    <button type="submit">I want to log out!</button>
                </form>  
                <%  }%>
            </div>
        </div>
        <div id="footer"><jsp:include page="components/footer.jsp"/></div>
    </div>
</body>  
</html>